<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\DB;

class CheckLogin
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        //检查用户是否登录
        $user = session('user');
        if(!$user){
            return response()->json([
                'code'=>403,
                'msg'=>'请先登录!',
                'data'=>[],
            ]);
        }

        return $next($request);
    }
}
